home *** CD-ROM | disk | FTP | other *** search
/ Precision Software Appli…tions Silver Collection 1 / Precision Software Applications Silver Collection Volume One (PSM) (1993).iso / tutor / dosguide.exe / HELPDOS.ZIP / IF.HLP < prev    next >
Text File  |  1985-09-03  |  2KB  |  47 lines

  1. ----------------------  IF - Internal Batch Subcommand  ------------------------
  2.  
  3. IF allows conditional execution of lines in a Batch File.  This allows control
  4.    of the order of execution of lines based on a true/false condition.
  5.  
  6. FORMAT:   IF [NOT] condition command
  7.  
  8. REMARKS:
  9.  
  10.    "condition" may be one of the following:
  11.  
  12.           string1==string2  - specifies that if "string1" is identical to
  13.                               "string2" (including upper and lower case
  14.                               letters), then "condition" is true.
  15.           ERRORLEVEL number - specifies that if the exit code of the previously
  16.                               run program is "number" or higher, then
  17.                               "condition" is true.
  18.           EXIST filespec    - specifies that if the file named in "filespec"
  19.                               exists, then "condition" is true.  Path names are
  20.                               not allowed in "filespec."  Global characters
  21.                               (* and ?) are allowed.
  22.  
  23.    command  - a command for DOS to execute.
  24.  
  25.    NOT      - specifies that "command" is to be executed if "condition" is
  26.               false.
  27.  
  28.    When the IF "condition" is true (false, if NOT is specified) then "command"
  29.    is executed.  Otherwise, "command" is ignored and the following line of the
  30.    batch file is executed.
  31.  
  32. EXAMPLE:
  33.  
  34. In this example, the replaceable parameter, %1, represents the name of a file.
  35. If the file is found on the specified drive, then the IF "condition" is true and
  36. "GOTO PRINT" will be executed.  If the file is not found, "GOTO PRINT" will be
  37. ignored and the next line "REM File %1 not found" will be executed.
  38.  
  39.           REM Print the File if it exists
  40.           IF EXIST %1 GOTO PRINT
  41.           REM File %1 not found
  42.           GOTO END
  43.           :PRINT
  44.           PRINT %1
  45.           :END
  46.           REM End of Batch File
  47.